let Router=require('koa-router')
let {
    userValitor,
    userExist,
    bcryptPassword,
    loginCheck
    }=require('../middleware/user.js')

 let {
    register,
    login,
    changePwd
 }=require('../control/user.js')

 let {
     auth
 }=require('../middleware/auth.js')

//userValitor,userExist,cryptPassword,

let router=new Router({prefix:'/user'})  //设置前缀
//1-判断数据不能为空，2-判断用户是否已经存在，3-密码加密，4-存入数据库
router.post('/register',userValitor,userExist,bcryptPassword,register)
router.post('/login',userValitor,loginCheck,login)
router.post('/changepwd',userValitor,auth,bcryptPassword,changePwd)

module.exports=router